package com.wzy.portfolio.handlers;

import com.wzy.portfolio.model.StockHistoryReq;
import com.wzy.portfolio.service.StockService;
import com.wzy.portfolio.utils.DateTool;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;

@Component
@Slf4j
public class StockJob {

    @Autowired
    StockService stockService;

    @XxlJob("stockMonitor")
    public ReturnT<String> gpDayDataJob() {
        log.info("--->监控股票阈值开始<---");
        String time1 = DateTool.DateToString(new Date(), "yyyy-MM-dd")+" 09:25:00";
        String time2 = DateTool.DateToString(new Date(), "yyyy-MM-dd")+" 11:35:00";
        String time3 = DateTool.DateToString(new Date(), "yyyy-MM-dd")+" 13:00:00";
        String time4 = DateTool.DateToString(new Date(), "yyyy-MM-dd")+" 15:10:00";
        if( DateTool.isBetween(time1,time2)||DateTool.isBetween(time3,time4)){
            stockService.stockMonitor();
        }
        return ReturnT.SUCCESS;
    }

    @XxlJob("stockDayData")
    public ReturnT<String> stockDayDataJob() {
        log.info("--->股票当日数据入库<---");
        stockService.stockDayData();
        return ReturnT.SUCCESS;
    }

    @XxlJob("historyPriceQueueJob")
    public ReturnT<String> historyPriceQueueJob() {
        log.info("--->消费股票历史数据队列<---");
        stockService.historyPriceQueue();
        return ReturnT.SUCCESS;
    }

}
